package cn.jly.bigdata.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @author lanyangji
 * @date 2019/11/27 21:34
 */
object Spark06_CheckPoint {

  def main(args: Array[String]): Unit = {

    val sc = new SparkContext(new SparkConf().setMaster("local[*]").setAppName("test-checkPoint"))

    // 设置检查点目录
    sc.setCheckpointDir("check-point")

    println(s"检查点存储目录---${sc.getCheckpointDir}")

    val mapRdd: RDD[String] = sc.makeRDD(List("tom")).map(_.toString + System.currentTimeMillis())

    // 做checkPoint
    mapRdd.checkpoint()

    mapRdd.foreach(println)
    mapRdd.foreach(println)
    mapRdd.foreach(println)

    println(mapRdd.toDebugString)

    sc.stop()
  }
}
